package homework;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class DictServer extends EchoServer{
    private Map<String,String> dict = new HashMap<>();
    public DictServer(int port) throws SocketException {
        super(port);

        dict.put("cat", "小猫");
        dict.put("dog", "小狗");
        dict.put("bird", "小鸟");
        dict.put("fish", "鱼");
        dict.put("cat", "小猫");
        dict.put("hello", "你好");
        dict.put("bye", "再见");
        dict.put("thank you", "谢谢");
        dict.put("I love you", "我很爱你");
        dict.put("you are welcome", "你很welcome");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request, "词典中没有该单词");
    }

    public static void main(String[] args) throws IOException {
        DictServer dictServer = new DictServer(9090);
        dictServer.start();
    }
}
